# Contributor: Newbyte <newbyte@disroot.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=py3-pydantic
pkgver=2.8.2
pkgrel=0
pkgdesc="Data parsing and validation using Python type hints"
url="https://github.com/samuelcolvin/pydantic"
arch="noarch"
license="MIT"
depends="py3-typing-extensions py3-annotated-types py3-pydantic-core"
makedepends="py3-gpep517 py3-hatchling py3-wheel py3-hatch-fancy-pypi-readme"
checkdepends="py3-hypothesis py3-pytest py3-pytest-mock py3-pytest-benchmark py3-dirty-equals py3-cloudpickle py3-faker py3-rich py3-email-validator"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/samuelcolvin/pydantic/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/pydantic-$pkgver"

# Tests broken on Python 3.12.
options="!check"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	.testenv/bin/python3 -m pytest --benchmark-disable \
		--ignore=tests/test_docs.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
a9ef0ee54fac0d06e53effd4db793559e5d2779b5df53b5b9eceb0839c3c7dbd56224424b4d418d18932dc5341132c8a9bc159138badcbc12b957412d4d229f2  py3-pydantic-2.8.2.tar.gz
"
